import java.util.Scanner;

import com.sun.javafx.collections.MappingChange.Map;

import java.util.Arrays;
import java.util.HashMap;

public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        Scanner scaner = new Scanner(System.in);
        int[] nums = { 2, 7, 11, 15 };
        int target = 9;
        int[] result = solution.twoSum(nums, target);
        System.out.println(result[0]);
        System.out.println(result[1]);
    }

    public int[] twoSum(int[] nums, int target) {
        int[] result=new int[2];
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i =0;i<nums.length;i++){
            if(map.containsKey(target-nums[i])){
                result[0]= map.get(target-nums[i]);
                result[1]= i;
                return result;
            }else{
                map.put(nums[i],i);
            }
        }
        return result;
    }
}
